/**
 * 添加新的好友
 */
import { addNewFriend } from "../../../model/service/chat/searchFriend";
import * as chatUtil from "../../../model/service/chat";
 
export default async function addNewFriends(ctx: Context, next: Next): Promise<void> {
  const { body } = ctx.request;
  const { fromUser, userId } = body

  if (!fromUser || !userId) {
    ctx.api.fail(-1, '添加失败')
  }

  await addNewFriend( body );
  const friendList = await chatUtil.getFriendList(userId);
  ctx.api.success(friendList, 'sucess')
  return next();
}